package com.wms.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wms.mapper.LogisticsCompanyMapper;
import com.wms.pojo.LogisticsCompany;
import com.wms.pojo.PageResult;
import com.wms.service.LogisticsCompanyService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogisticsCompanyServiceImpl extends ServiceImpl<LogisticsCompanyMapper,LogisticsCompany> implements LogisticsCompanyService {
    @Override
    public PageResult queryPage(Integer page,Integer pageSize ,String companyName, String linkUser) {
        PageHelper.startPage(page,pageSize);
        List<LogisticsCompany> logisticsCompanies = getBaseMapper().selectList(Wrappers.<LogisticsCompany>lambdaQuery()
                .like(ObjectUtil.isAllNotEmpty(companyName), LogisticsCompany::getCompanyName, companyName)
                .like(ObjectUtil.isAllNotEmpty(linkUser), LogisticsCompany::getLinkUser, linkUser));
        Page<LogisticsCompany> companyPage = (Page<LogisticsCompany>) logisticsCompanies;
        return new PageResult(companyPage.getTotal(),companyPage.getResult());
    }
}
